package stack;

public class RemoveDuplicates {
    public String code(String ss) {
        char[] s = ss.toCharArray();
        StringBuffer ret = new StringBuffer();

        for (int i = 0; i < s.length; i++){
            if (ret.length() > 0 && s[i] == ret.charAt(ret.length() - 1)){
                ret.deleteCharAt(ret.length() - 1);
            }else {
                ret.append(s[i]);
            }
        }

        return ret.toString();
    }
}
